//
//  KINGStatusForwardCell.swift
//  肉荣微博
//
//  Created by king on 15/8/3.
//  Copyright © 2015年 king. All rights reserved.
//

import UIKit

class KINGStatusForwardCell: KINGStatusCell {

    override var status:KINGStatuses? {
        didSet {
            let name = status?.retweetedStatus?.my_user?.name ?? ""
            let text = status?.retweetedStatus?.text ?? ""
            contentLabel.text = "@" + name + ":" + text
        }
    }
    
    override func setupUI() {
        super.setupUI()
        contentView.insertSubview(backButton, belowSubview: pictureView)
        contentView.insertSubview(contentLabel, aboveSubview: backButton)
        
        backButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: messageLabel, size: nil, offset: CGPoint(x: -statusCellContolMargin, y: statusCellContolMargin))
        backButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottomView, size: nil)
        
        contentLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backButton, size: nil, offset: CGPoint(x: statusCellContolMargin, y: statusCellContolMargin))
        
        pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLabel, size: nil, offset: CGPoint(x: 0, y: statusCellContolMargin))
        contentView.addConstraint(NSLayoutConstraint(item: pictureView, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1.0, constant: 290))
        pictureWidthLayout = contentView.constraints.last
        contentView.addConstraint(NSLayoutConstraint(item: pictureView, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1.0, constant: 290))
        pictureHeightLayout = contentView.constraints.last
    }
    
/// 懒加载控件
    private lazy var backButton:UIButton = {
        let backBtn = UIButton()
        backBtn.backgroundColor = UIColor(white: 0.95, alpha: 1.0)
        return backBtn
    }()
    private lazy var contentLabel:UILabel = {
        let label = UILabel()
        //label.textAlignment = NSTextAlignment.Center
        label.preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2*CGFloat(statusCellContolMargin)
        label.numberOfLines = 0
        label.textColor = UIColor.darkGrayColor()
        label.font = UIFont.systemFontOfSize(13)
        return label
    }()
}
